/*
 * KeyValueObserver.java
 *
 * Created on November 3, 2006, 7:31 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.umn.cs5115.scheduler.framework;

import java.util.Set;

/**
 * An interface that listens to notifications produced by instances of any
 * KeyValueCoding object.
 * @author grant
 */
public interface KeyValueObserver
{
    /** 
     * Called when an observed key has changed. 
     * @param object The object that the change ocurred in.
     * @param key The key for the value that has changed.
     */
    public void valueChanged(KeyValueCoding object, String key);
    
    /**
     * Called to indicate that the value of a key which is a set has changed.
     * @param object The object that the change ocurred in.
     * @param key The key for which the value was modified.
     * @param mutation The operation applied to the old value of the set and
     * the modifyingSet to get the new value of the set.
     * @param modifyingSet The set used to modify the value of the key.
     */
    public void valueChanged(KeyValueCoding object, String key, SetMutationType mutation, Set modifyingSet);
    
    /** Specifies mutation types when sets change. */
    public static enum SetMutationType
    {
        /** Modify sets using the union of two sets. */
        UNION,
        /** Modify sets by taking their intersection. */
        INTERSECT,
        /** Modify sets by subtracting one set from another. */
        MINUS,
        /** Modify a set by completely replacing it with a different set. */
        REPLACE
    }
}